#include "CPlayer.h"
#include "CEnemy.h"
#include "SGD Wrappers/CSGD_DirectInput.h"
#include "SGD Wrappers/CSGD_TextureManager.h"
#include "ObjectManager.h"
#include "CCamera.h"

#include "CWorldEngine.h"
#include "CPhysics.h"
#include "ParticleEngine.h"
#include "ComboSystem.h"
#include "CUpgradeSystem.h"
#include "CAnimationEngine.h"
#include "CWeapon.h"

CPlayer::CPlayer()
{
	//SetImageID(CSGD_TextureManager::GetInstance()->LoadTexture("resources/graphics/SGD_MenuCursor.png", D3DCOLOR_XRGB(255, 255, 255)));
	SetWidth(32);
	SetHeight(64);
	m_nType = OBJ_PLAYER;
	m_nCurrentWeapon = 0;
	m_nGauntletLevel = 1;
	m_nSwordLevel = 1;
	m_nSpearLevel = 1;

	m_nGauntletComboExp = 0;
	m_nSwordComboExp = 0;
	m_nSpearComboExp = 0;

	m_nPlayerExp = 100000;
	m_nSwordExp = 0;
	m_nSpearExp = 0;
	m_nGauntletExp = 0 ;
	m_fTimer = 1.0f;
	m_bGauntletPickUp = false;
	m_nGoodCombo = false;

	currentAnimation = 0;

	LoadWeaponInfo();
	m_nAnimationIDs.push_back(CAnimationEngine::GetInstance()->Load("Resources/Saved Animations/Fist - Idle.bin", 255,255,255));
	m_nAnimationIDs.push_back(CAnimationEngine::GetInstance()->Load("Resources/Saved Animations/Fist - Walk.bin", 255,255,255));
	m_nAnimationIDs.push_back(CAnimationEngine::GetInstance()->Load("Resources/Saved Animations/Light Punch.bin", 255,255,255));
	m_nAnimationIDs.push_back(CAnimationEngine::GetInstance()->Load("Resources/Saved Animations/Medium Punch.bin", 255,255,255));
	m_nAnimationIDs.push_back(CAnimationEngine::GetInstance()->Load("Resources/Saved Animations/Heavy Punch.bin", 255,255,255));
	m_nAnimationIDs.push_back(CAnimationEngine::GetInstance()->Load("Resources/Saved Animations/Uppercut.bin",255,255,255));
	m_nAnimationIDs.push_back(CAnimationEngine::GetInstance()->Load("Resources/Saved Animations/1000 fist.bin",255,255,255));

	SetOffestX(( float )-CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->GetFrame()->GetAnchorX());
	SetOffestY(( float )-CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->GetFrame()->GetAnchorY()+7);



}
CPlayer::~CPlayer( void )
{
	for( unsigned int i = 0 ; i < m_vPlayerWeapons.size() ; ++i )
		delete m_vPlayerWeapons[ i ];
	for( unsigned int i = 0 ; i < m_vPlayerCombos.size(); ++i )
		delete m_vPlayerCombos[ i ];

	m_vPlayerCombos.clear();
	m_vPlayerWeapons.clear();
}

void CPlayer::Update(float fElapsedTime)
{
	//if( CSGD_DirectInput::GetInstance()->CheckBufferedKeysEx() == 0 )
	//{
	//	CAnimationEngine::GetInstance()->GetPlayingAnimations( 0 )->SetPosX( ( int )GetPosX() );
	//	CAnimationEngine::GetInstance()->GetPlayingAnimations( 0 )->SetPosY( ( int )GetPosY() );
	//	CAnimationEngine::GetInstance()->GetPlayingAnimations( 0 )->SetPlaying( true );
	//}
	ComboSystem::GetInstance()->Update( fElapsedTime );
	if(CSGD_DirectInput::GetInstance()->KeyDown(DIK_RIGHT))
	{
		SetVelX( 200.001f );
		SetFacingRight(true);
		//if(m_pID != NULL)
		//{
		//	if(CAnimationEngine::GetInstance()->GetPlayingAnimations(*m_pID)->GetIndexID() != 1)
		//	{
		//		//CAnimationEngine::GetInstance()->RemovePlayingAnimations(m_pID);
		//		//m_pID = CAnimationEngine::GetInstance()->AddPlayingAnimations(1, false);
		//		//CAnimationEngine::GetInstance()->GetPlayingAnimations(*m_pID)->SetLoop(false);
		//	}
		//}
		//else
		//{
		//	//m_pID = CAnimationEngine::GetInstance()->AddPlayingAnimations(1, false);
		//	//CAnimationEngine::GetInstance()->GetPlayingAnimations(*m_pID)->SetLoop(false);
		//}
		if(currentAnimation != 1)
		{
			CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetPlaying(false);
			currentAnimation = 1;
		}
		CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetFlipped(false);
		CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetPlaying(true);
	}

	if(CSGD_DirectInput::GetInstance()->KeyDown(DIK_LEFT))
	{
		SetVelX( -200.001f );
		SetFacingRight(false);
		//if(m_pID != NULL)
		//{
		//	if(CAnimationEngine::GetInstance()->GetPlayingAnimations(*m_pID)->GetIndexID() != -1)
		//	{
		//		//CAnimationEngine::GetInstance()->RemovePlayingAnimations(m_pID);
		//		//m_pID = CAnimationEngine::GetInstance()->AddPlayingAnimations(1, true);
		//		//CAnimationEngine::GetInstance()->GetPlayingAnimations(*m_pID)->SetLoop(false);
		//	}
		//}
		//else
		//{
		//	/*m_pID = CAnimationEngine::GetInstance()->AddPlayingAnimations(-1, true);
		//	CAnimationEngine::GetInstance()->GetPlayingAnimations(*m_pID)->SetLoop(false);*/
		//}
		if(currentAnimation != 1)
		{
			CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetPlaying(false);
			currentAnimation = 1;
		}
		CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetFlipped(true);
		CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetPlaying(true);
	}

	if( (GetVelX() < -5.0f && !GetFacingRight()))
		SetVelX( CPhysics::GetInstance()->IsWalkingLeft( GetVelX(), fElapsedTime ));
	else if((GetVelX() > 5.0f && GetFacingRight()))
		SetVelX( CPhysics::GetInstance()->IsWalkingRight( GetVelX(), fElapsedTime ));
	else if(GetVelX() >= -5.0f  && GetVelX() <= 5.0f)
	{
		//if(m_pID != NULL)
		//{
		//	int index = CAnimationEngine::GetInstance()->GetPlayingAnimations(*m_pID)->GetIndexID();
		//	if(index != 0 && index != 2 && index != 3 && index != 4)
		//	{
		//		CAnimationEngine::GetInstance()->RemovePlayingAnimations(m_pID);
		//		m_pID = CAnimationEngine::GetInstance()->AddPlayingAnimations(0, true);
		//	}
		//}
		//else
		//{
		//	m_pID = CAnimationEngine::GetInstance()->AddPlayingAnimations(0, false);
		//	CAnimationEngine::GetInstance()->GetPlayingAnimations(*m_pID)->SetLoop(true);
		//}

		if((currentAnimation != 0 && currentAnimation != 2 && currentAnimation != 3 && currentAnimation != 4 && currentAnimation != 5  && currentAnimation != 6) ||
			!CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->GetPlaying())
		{
			CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetPlaying(false);
			currentAnimation = 0;
		}
		if(!GetFacingRight())
			CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetFlipped(true);
		else
			CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetFlipped(false);

		CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetPlaying(true);

		SetVelX(0);
	}

	/*if( CPhysics::GetInstance()->GetIsFalling() )
	SetVelY( CPhysics::GetInstance()->IsFalling( GetVelY(), fElapsedTime ) );*/

	if( currentAnimation == 1 || currentAnimation == 2 ||currentAnimation == 0 )
		m_fTimer -= fElapsedTime ;
	if(	m_fTimer < 0.0f )
	{
		ComboSystem::GetInstance()->Clear();
		ComboSystem::GetInstance()->SetTimerStart( false );
	}
	if( CWorldEngine::GetInstance()->CheckCollision( this ) == WATER )
	{
		CPhysics::GetInstance()->SetInWater( true );
		CPhysics::GetInstance()->SetIsFlying( false );
	}
	else
		CPhysics::GetInstance()->SetInWater( false );

	if( CPhysics::GetInstance()->GetInWater() )
	{

		if(CSGD_DirectInput::GetInstance()->KeyDown(DIK_RIGHT))
		{
			SetVelX( 50.001f );
			SetFacingRight(true);
		}
		if( GetVelX() > 0.0f )
			SetVelX( CPhysics::GetInstance()->IsWalkingRight( GetVelX() , fElapsedTime ) );

		if(CSGD_DirectInput::GetInstance()->KeyDown(DIK_LEFT))
		{
			SetVelX( -50.001f );
			SetFacingRight(false);
		}
		if( GetVelX() < 0.0f )
			SetVelX( CPhysics::GetInstance()->IsWalkingLeft( GetVelX(), fElapsedTime ) );

		if( CPhysics::GetInstance()->GetIsFalling() )
			SetVelY( CPhysics::GetInstance()->IsFalling( GetVelY(), fElapsedTime ) );
		if( CSGD_DirectInput::GetInstance()->KeyDown( DIK_SPACE ) )
		{
			SetVelY( -50.001f  );
			CPhysics::GetInstance()->SetIsSwimming( true );
		}
		else
		{
			CPhysics::GetInstance()->IsFalling( GetVelY(), fElapsedTime );
		}
		if( CPhysics::GetInstance()->GetIsSwimming() )
		{
			if( CWorldEngine::GetInstance()->CheckCollision( this ) != SOLID )
			{
				SetVelY( CPhysics::GetInstance()->IsSwimming( GetVelY(), fElapsedTime ) );
			}
			else
			{
				CPhysics::GetInstance()->SetIsSwimming( false );
				SetVelY( 0.0f );
			}
		}
		else
			SetVelY( CPhysics::GetInstance()->IsFalling( GetVelY() , fElapsedTime ) );
	}
	else 
	{
		if( CWorldEngine::GetInstance()->CheckCollision( this ) != SOLID && CWorldEngine::GetInstance()->CheckCollision( this ) != WATER )
		{
			SetVelY( CPhysics::GetInstance()->IsFalling( GetVelY(), fElapsedTime ) );

		}
		else
		{
			SetVelY( 0 );
			CPhysics::GetInstance()->SetIsJumping( false );
		}
		if( !CPhysics::GetInstance()->GetIsJumping()  && CSGD_DirectInput::GetInstance()->KeyPressed(DIK_SPACE))
		{
			CPhysics::GetInstance()->SetIsJumping( true );
			SetVelY( -350.001f );
			SetPosY(GetPosY()-10);
		}
	}
	if( CWorldEngine::GetInstance()->CheckCollision( this ) == SOLID )
		CPhysics::GetInstance()->SetIsFlying( false );

	if(  CSGD_DirectInput::GetInstance()->KeyPressed( DIK_F ) )
	{
		if (CPhysics::GetInstance()->GetIsJumping() )
		{
			CPhysics::GetInstance()->SetIsFlying( !CPhysics::GetInstance()->GetIsFlying() );
		}
	}
	if( CPhysics::GetInstance()->GetIsFlying() )
	{
		SetVelY( CPhysics::GetInstance()->IsFlying( GetVelY(), fElapsedTime ) );
		if( CSGD_DirectInput::GetInstance()->KeyDown( DIK_UP ) )
			SetPosY( GetPosY() - 1.001f );
		if( CSGD_DirectInput::GetInstance()->KeyDown( DIK_DOWN ) )
			SetPosY( GetPosY()  + 1.001f );
	}

	if( currentAnimation != 2 )
	{
		if( CAnimationEngine::GetInstance()->GetAnimations( m_nAnimationIDs[ 2 ] )->GetPlaying() == false )
			if( CAnimationEngine::GetInstance()->GetAnimations( m_nAnimationIDs[ 3 ] )->GetPlaying() == false ) 
				if( CAnimationEngine::GetInstance()->GetAnimations( m_nAnimationIDs[ 4 ] )->GetPlaying() == false ) 
					if( CSGD_DirectInput::GetInstance()->KeyPressed( DIK_Z ) )
					{
						m_fTimer = 1.0f;
						m_nGoodCombo =  ComboSystem::GetInstance()->CheckComboInput( CSGD_DirectInput::GetInstance()->CheckBufferedKeysEx(), 
							GetCurrentWeapon() , fElapsedTime ) ;
						if(currentAnimation != 2)
						{
							CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetPlaying(false);
							currentAnimation = 2;
						}
						CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetLoop(false);
						CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetPlaying(true);
					}
	}
	if( currentAnimation != 3 )
	{
		if( CAnimationEngine::GetInstance()->GetAnimations( m_nAnimationIDs[ 2 ] )->GetPlaying() == false )
			if( CAnimationEngine::GetInstance()->GetAnimations( m_nAnimationIDs[ 3 ] )->GetPlaying() == false ) 
				if( CAnimationEngine::GetInstance()->GetAnimations( m_nAnimationIDs[ 4 ] )->GetPlaying() == false ) 
					if( CSGD_DirectInput::GetInstance()->KeyPressed( DIK_X )  )
					{
						m_fTimer = 1.0f;
						m_nGoodCombo =  ComboSystem::GetInstance()->CheckComboInput( CSGD_DirectInput::GetInstance()->CheckBufferedKeysEx(), 
							GetCurrentWeapon() , fElapsedTime ) ;
						if(currentAnimation != 3)
						{
							CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetPlaying(false);
							currentAnimation = 3;
						}
						CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetLoop(false);
						CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetPlaying(true);
					}
	}
	if( currentAnimation != 4 )
	{
		if( CAnimationEngine::GetInstance()->GetAnimations( m_nAnimationIDs[ 2 ] )->GetPlaying() == false )
			if( CAnimationEngine::GetInstance()->GetAnimations( m_nAnimationIDs[ 3 ] )->GetPlaying() == false ) 
				if( CAnimationEngine::GetInstance()->GetAnimations( m_nAnimationIDs[ 4 ] )->GetPlaying() == false ) 
					if( CSGD_DirectInput::GetInstance()->KeyPressed( DIK_C ) )
					{
						m_fTimer = 1.0f;
						m_nGoodCombo =  ComboSystem::GetInstance()->CheckComboInput( CSGD_DirectInput::GetInstance()->CheckBufferedKeysEx(), 
							GetCurrentWeapon() , fElapsedTime ) ;
						if(currentAnimation != 4)
						{
							CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetPlaying(false);
							currentAnimation = 4;
						}
						CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetLoop(false);
						CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetPlaying(true);
					}
	}	
	//if( m_fTimer < 1.0 )
	//{
	//	m_nGoodCombo =  ComboSystem::GetInstance()->CheckComboInput( CSGD_DirectInput::GetInstance()->CheckBufferedKeysEx(), 
	//		GetCurrentWeapon() , fElapsedTime ) ;
	//}
	//
	if( CSGD_DirectInput::GetInstance()->KeyPressed( DIK_NUMPAD3 ) )
	{
		m_nGoodCombo = false;
	}

	CAnimationEngine::GetInstance()->SetAniInfo(m_nAnimationIDs[currentAnimation], ( int )GetPosX(), ( int )GetPosY());


	CCamera::GetInstance()->MoveCamera(CBase::GetCollisionRect());

	CBase::Update(fElapsedTime);
}
bool CPlayer::CheckCollision( CBase* pBase )
{
	if( pBase->GetType() == OBJ_PLAYER )
	{
		return false;
	}
	if(pBase->GetType() == OBJ_ENEMY )
	{
		/*if( IntersectRect( &empty,&pBase->GetCollisionRect(), &CAnimationEngine::GetInstance()->GetAnimations( m_nAnimationIDs[ currentAnimation ] )->GetWeaponRect() )
		{
		}*/
		return false;
	}
	if(pBase->GetType() == OBJ_EXPORB)
	{
		RECT temp;
		if(IntersectRect(&temp, &GetCollisionRect(), &(pBase->GetCollisionRect())))
		{
			m_nPlayerExp += 500;
			ObjectManager::GetInstance()->RemoveObject(pBase);
			return true;
		}
	}
	if(pBase->GetType() == OBJ_INVERSE)
	{
		if(pBase->GetIsActive())
		{
			RECT temp;
			if(IntersectRect(&temp, &GetCollisionRect(), &pBase->GetCollisionRect()))
			{
				if((temp.bottom - temp.top) > (temp.right-temp.left))
				{
					if(temp.right == GetCollisionRect().right)
					{
						SetPosX(GetPosX()-(temp.right-temp.left));
					}
					else
					{
						SetPosX(GetPosX()+(temp.right-temp.left));
					}
				}
				else
				{
					if(temp.bottom == GetCollisionRect().bottom)
					{
						SetPosY(GetPosY()-(temp.bottom-temp.top));
					}
					else
					{
						SetPosY(GetPosY()+(temp.bottom-temp.top));
					}
				}
				return true;
			}
		}
	}
	if(pBase->GetType() == OBJ_GAUNTLET)
	{
		if(IntersectRect(&RECT(), &GetCollisionRect(), &pBase->GetCollisionRect()))
		{
			m_bGauntletPickUp = true;
			ObjectManager::GetInstance()->RemoveObject(pBase);
			return true;
		}
	}

	return false;
}
RECT CPlayer::GetCollisionRect()
{
	RECT playerRect = {0,0,0,0};
	//playerRect.left = ( long )GetPosX();
	//playerRect.top = ( long )GetPosY();
	//playerRect.right = ( long )( GetPosX() + ( GetWidth()  * GetScaleX() ) );
	//playerRect.bottom = ( long )( GetPosY() + ( GetHeight() * GetScaleY() ) );
	playerRect.left = CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->GetCollisionRect().left + CCamera::GetInstance()->GetCameraPosX();
	playerRect.right = CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->GetCollisionRect().right + CCamera::GetInstance()->GetCameraPosX();
	playerRect.top = CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->GetCollisionRect().top + CCamera::GetInstance()->GetCameraPosY();
	playerRect.bottom = CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->GetCollisionRect().bottom + CCamera::GetInstance()->GetCameraPosY();

	return playerRect;
}
RECT CPlayer::GetAttackRect( void )
{
	RECT attackRect = { 0,0,0,0 };

	attackRect.left = CAnimationEngine::GetInstance()->GetAnimations( m_nAnimationIDs[ currentAnimation ] )->GetWeaponRect().left  + CCamera::GetInstance()->GetCameraPosX();
	attackRect.right = CAnimationEngine::GetInstance()->GetAnimations( m_nAnimationIDs[ currentAnimation ] )->GetWeaponRect().right  + CCamera::GetInstance()->GetCameraPosX();
	attackRect.top = CAnimationEngine::GetInstance()->GetAnimations( m_nAnimationIDs[ currentAnimation ] )->GetWeaponRect().top  + CCamera::GetInstance()->GetCameraPosY();
	attackRect.bottom = CAnimationEngine::GetInstance()->GetAnimations( m_nAnimationIDs[ currentAnimation ] )->GetWeaponRect().bottom  + CCamera::GetInstance()->GetCameraPosY();

	return attackRect;
}
void CPlayer::Render()
{
	CAnimationEngine::GetInstance()->Render();

	//if(GetFacingRight() )
	//{
	//	CSGD_TextureManager::GetInstance()->Draw(GetImageID(), (int)GetPosX()- CCamera::GetInstance()->GetCameraPosX(),
	//		(int)GetPosY()- CCamera::GetInstance()->GetCameraPosY(), GetScaleX(),GetScaleY());

	//}
	//else
	//{
	//	CSGD_TextureManager::GetInstance()->Draw(GetImageID(), ((int)GetPosX() + GetWidth()*GetScaleX()) - CCamera::GetInstance()->GetCameraPosX(),
	//		(int)GetPosY()- CCamera::GetInstance()->GetCameraPosY(),-GetScaleX(),GetScaleY());
	//}
	RECT draw;
	draw.left = ( long )GetPosX();
	draw.top = ( long )( GetPosY() );
	draw.right = ( long )( GetPosX() + 32);
	draw.bottom = ( long )( GetPosY() + 64 );
	if( m_nGoodCombo != 0 )
	{
		if(currentAnimation != m_nGoodCombo)
		{
			CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetPlaying(false);
			currentAnimation = m_nGoodCombo;
		}
		CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetLoop(false);
		CAnimationEngine::GetInstance()->GetAnimations(m_nAnimationIDs[currentAnimation])->SetPlaying(true);
		m_nGoodCombo = 0;
	}
	//char buffer[ 40 ];
	//sprintf_s( buffer," Combo Timer: %.3f ",m_fTimer );
	//CSGD_Direct3D::GetInstance()->DrawText( buffer,GetPosX() - CCamera::GetInstance()->GetCameraPosX() ,
	//	GetPosY() - CCamera::GetInstance()->GetCameraPosY() );

	//RECT temp = CBase::GetCollisionRect();
	//temp.left -= CCamera::GetInstance()->GetCameraPosX();
	//temp.right -= CCamera::GetInstance()->GetCameraPosX();
	//temp.top -= CCamera::GetInstance()->GetCameraPosY();
	//temp.bottom -= CCamera::GetInstance()->GetCameraPosY();

	//CSGD_Direct3D::GetInstance()->DrawRect(temp,0,0,0);
}
void CPlayer::LoadWeaponInfo( void )
{
	ifstream is;
	is.open( "Resources/Data Files/WeaponInfo.dat" );
	if( is.is_open() )
	{
		char temp[ 10 ] = { 0 };
		char weap[ 20 ] = { 0 };
		for( int i = 0 ; i < 12 ; ++i )
		{
			is.getline( weap ,sizeof( weap )  ); 

			is.getline( temp ,sizeof( temp )  );
			int nLevel = atoi( temp );
			is.getline( temp ,sizeof( temp )  );
			int nLight = atoi( temp );
			is.getline( temp ,sizeof( temp )  );
			int nMedium = atoi( temp );
			is.getline( temp ,sizeof( temp )  );
			int nHeavy = atoi( temp );
			is.getline( temp ,sizeof( temp )  );
			int nXPToLevel = atol( temp );

			CWeapon* weapon = new CWeapon( weap , nLevel, nLight, nMedium, nHeavy, nXPToLevel );
			m_vPlayerWeapons.push_back( weapon );
		}
	}
	is.close();
}
string CPlayer::GetCurrentWeapon( void )
{
	string name;
	switch( m_nCurrentWeapon )
	{
	case 0:
		{
			name = "Gauntlet";
			return name;
			break;
		}
	case 1:
		{
			name = "Spear";
			return name;
			break;
		}
	case 2:
		{
			name = "Sword";
			return name;
			break;
		}
	};
	return "Gauntlet";
}
// SearchWeapon 
// Returns the index of the weapon to use in the GetWeapon function to pull up the upgrade info.
int CPlayer::SearchWeapon( void )
{
	int nCurrentWeaponLevel = 0;
	switch( m_nCurrentWeapon )
	{
	case 0:
		{
			nCurrentWeaponLevel = GetGauntletLevel();
			break;
		}
	case 1:
		{
			nCurrentWeaponLevel = GetSpearLevel();
			break;
		}
	case 2:
		{
			nCurrentWeaponLevel = GetSwordLevel();
			break;
		}
	default:
		{
			nCurrentWeaponLevel = 1;
			break;
		}
	};
	for( unsigned int i = 0; i < m_vPlayerWeapons.size(); ++i )
	{
		if( m_vPlayerWeapons[ i ]->GetWeaponType() == GetCurrentWeapon() && m_vPlayerWeapons[ i ]->GetWeaponLevel() == nCurrentWeaponLevel )
			return  i ;
	}
	return -1;
}
// Search Weapon ( string )
// Returns the information at an index of the specified weapon.
int CPlayer::SearchWeapon( string strWeaponName )
{
	int nCurrentWeaponLevel = 0;
	if( strcmp(strWeaponName.c_str(), "Gauntlet" ) == 0 )
	{
		nCurrentWeaponLevel = GetGauntletLevel();
	}
	else if( strcmp( strWeaponName.c_str(), "Spear" ) == 0 )
	{
		nCurrentWeaponLevel = GetSpearLevel();
	}
	else if( strcmp( strWeaponName.c_str(), "Sword" ) == 0 )
	{
		nCurrentWeaponLevel = GetSwordLevel();
	}
	else
	{
		nCurrentWeaponLevel = 1;
	}
	for( unsigned int i = 0; i < m_vPlayerWeapons.size(); ++i )
	{
		if( m_vPlayerWeapons[ i ]->GetWeaponType() == strWeaponName && m_vPlayerWeapons[ i ]->GetWeaponLevel() == nCurrentWeaponLevel )
			return  i ;
	}
	return -1;
}
void CPlayer::SetPlayerCombos( void )
{
	LoadPlayerCombos();
}
void CPlayer::LoadPlayerCombos( void )
{
	char weapon[ 10 ];
	char name[ 40 ];
	char buttons[ 10 ];
	char active[ 2 ];
	char damage[ 4 ];
	int nDamage = 0;

	ifstream is;
	is.open("Resources/Data Files/Combos.dat");
	if( is.is_open() )
	{
		for( int i = 0 ; i < 12 ; ++i )
		{
			is.getline( weapon, sizeof( weapon ) );

			is.getline( name, sizeof( name ) );

			is.getline( buttons, sizeof( buttons ) );

			is.getline( damage, sizeof( damage ) );
			int nDamage = atoi( damage );

			is.getline( active, sizeof( active ) );
			int nActive = atoi( active );

			if( nActive == 1 )
			{
				CCombo* combo = new CCombo( weapon, name , buttons, nDamage, true );
				m_vPlayerCombos.push_back( combo );
			}
			else
			{
				CCombo* combo = new CCombo( weapon, name , buttons, nDamage, false );
				m_vPlayerCombos.push_back( combo );
			}
		}
		is.close();
	}
}